﻿Imports System.IO

Public Class ClearFile
    Implements IClear

    Public Sub ClearFile(ByVal fif As System.IO.FileInfo) Implements IClear.ClearFile
        Try
            Dim filename As String = fif.FullName.ToLower
            Select Case Path.GetExtension(filename)
                Case ".vmxf", ".vmsd", ".log", ".nvram"
                    If fif.IsReadOnly = True Then
                        fif.IsReadOnly = False
                    End If
                    fif.Delete()
                    Console.WriteLine(fif.FullName)
            End Select
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
        
    End Sub

    Public Sub CrearDir(ByVal dif As System.IO.DirectoryInfo) Implements IClear.CrearDir
        Try
            Select Case dif.Name.ToLower
                Case "caches"
                    dif.Delete(True)
                    Console.WriteLine(dif.FullName)
                Case Else
                    If dif.Name.ToLower.EndsWith(".vmx.lck") Then
                        dif.Delete(True)
                        Console.WriteLine(dif.FullName)
                    End If
            End Select
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
    End Sub

End Class
